package com.wx.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.wx.model.Users;
import com.wx.serviceImpl.UserInfoServiceImpl;

/**
 * Servlet implementation class UserInforServlet
 */
@WebServlet("/servlet/UserInforServlet")
public class UserInforServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UserInforServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username =(String) request.getSession().getAttribute("username");
		String truename = request.getParameter("truename");
		String gender = request.getParameter("gender");
		String phone = request.getParameter("phone");
		String adress = request.getParameter("adress");
		String postcode = request.getParameter("postcode");
		Users user = new Users();
		user.setUsername(username);
		user.setTruename(truename);
		user.setGender(gender);
		user.setPhone(phone);
		user.setHome(adress);
		user.setPostcode(Integer.parseInt(postcode));
		try {
			new UserInfoServiceImpl().modifyUserInfo(user);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
